package Package5;

public class GirlFriend {
    private String name;
    private int age;

    public GirlFriend() {
        System.out.println("hello world");
    }

    public GirlFriend(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setAge(int age) {
        if (age >= 18 && age <= 30) {
            this.age = age;
        } else {
            System.out.println("年龄输入不合理");
        }
    }

    public int getAge() {
        return age;
    }

    public String toString() {
        return "GirlFriend{name = " + name + ", age = " + age + "}";
    }
}
